import { beforeAll, describe, test, expect } from 'vitest';
import { execSync } from 'child_process';
import { FileUtils } from '~/core/extensions';

let rowArr: Array<Array<string>> = []

beforeAll(() => {
    execSync('npm run build', { encoding: 'utf-8' });
    execSync('node dist/index.js', { encoding: 'utf-8' });
    let result = FileUtils.readTextFile('result.json');
    result = result.slice(result.indexOf('\n'));
    rowArr = JSON.parse(result).rows;
})

describe('MatchTest', () => {
    test('MatchTest_001', () => {
        const expectFile = 'sample.ts';
        let rows = rowArr.filter((row: Array<String>) => {
            return row[0].includes(expectFile);
        });
        expect(rows.length).toBe(3);
    });

})